<template>
  <div>
    <!-- <slot></slot> -->
  </div>
</template>

<script setup>
import { useSlots, inject, onMounted } from 'vue';
import { registerKey } from './config.js';

const props = defineProps({
  prop: {
    type: String,
    default: '',
  },
  label: {
    type: String,
    default: '',
  },
  width: {
    type: Number,
    default: 0,
  },
  fixed: {
    type: String,
    default: '',
  },
  type: {
    type: String,
    default: '',
  },
  align: {
    type: String,
    default: '',
  },
});

const slots = useSlots();

// 使用 inject 获取注册方法
const registerColumn = inject(registerKey);

// 构建列配置对象，包含插槽信息
const columnConfig = {
  prop: props.prop,
  label: props.label,
  width: props.width,
  fixed: props.fixed,
  type: props.type,
  align: props.align,
  slot: slots.default,
};

onMounted(() => {
  console.log('Registering column:', columnConfig);
  if (registerColumn) {
    registerColumn(columnConfig);
  }
});
</script>
